package top.wenzz.manage.system.manage.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import top.wenzz.commons.vo.RetMsg;
import top.wenzz.manage.system.manage.entity.OvertimeRecord;
import top.wenzz.manage.system.manage.service.OvertimeStatisticsService;

/**
 * 加班记录controller
 * Created by 钟廷员 on 2016/12/15.
 */
@RestController
@RequestMapping("overtime/statistics")
public class OvertimeStatisticsController {

    @Autowired
    private OvertimeStatisticsService overtimeStatisticsService;

    @RequestMapping( value = "pageQuery", method = RequestMethod.POST )
    public Object statistics(@RequestBody OvertimeRecord entity) {
        if(entity.getQueryDate() == null || entity.getQueryDate().length != 2
                || entity.getQueryDate()[0] == null || entity.getQueryDate()[1] == null) {
            return RetMsg.error("统计时间不能为空");
        }
        return RetMsg.success(overtimeStatisticsService.statistics(entity));
    }
}
